<#-- Copyright 2010 Canadensys -->
<#include "_inc/ftl/common.ftl">

<@assignTitle str=locale.download_title1/>
<#assign currentPage="download"/>

<#include "_inc/ftl/header.ftl">
<script type="text/javascript">
$(document).ready(function(){
	function error(){
		$(".error").show();
		$(".ready").hide();
		$(".busy").hide();
	}
	function success(data){
		if(data == "success"){
			$(".ready").show();
			$(".busy").hide();
			$(".error").hide();
		}
		else{
			error();
		}
	}
	
	function download(url){
	   $.ajax({url:url,cache:false,data:document.location.search.substr(1),success:success,error:error});
	}
	<#if filename?has_content == true && format?has_content == true>
	   var filename = "${filename}";
		<#if format == "txt">
			var url = "_ajax/csv.jsp";
		<#else>
			var url = "_ajax/dwc.jsp";
		</#if>
		setTimeout(function(){download(url)},1000);
		//setTimeout(download,1000,url);
	</#if>
});
</script>
<#include "_inc/ftl/menu.ftl">

<div class="busy">
	<h1><@display str=locale.download_title2/> <img src="images/ajax-loader.gif"/></h1>
	<p><@display str=locale.download_msg1/></p>
	<#if filename?has_content == true>
	<blockquote><a href="${downloadURL}" onclick="_gaq.push(['_trackEvent', '<#if format == "txt">Text<#else>Archive</#if>', 'Pre-Download', 'Checklist builder']);">${filename}</a></blockquote>
	</#if>
	<p><@display str=locale.download_msg2/></p>
</div>
<div class="ready" style="display:none">
	<h1><@display str=locale.download_title3/></h1>
	<p><@display str=locale.download_msg3/></p>
	<#if filename?has_content == true>
	<blockquote><a href="${downloadURL}" onclick="_gaq.push(['_trackEvent', '<#if format == "txt">Text<#else>Archive</#if>', 'Download', 'Checklist builder']);">${filename}</a></blockquote>
	</#if>
	<p><@display str=locale.download_msg4/></p>
</div>
<div class="error" style="display:none">
	<h1><@display str=locale.download_title4/></h1>
	<p><@display str=locale.download_msg5/></p>
</div>

<#include "_inc/ftl/footer.ftl">